'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /*
      Add altering commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.createTable('users', { id: Sequelize.INTEGER });
    */
    const { INTEGER, DATE, STRING, NOW } = Sequelize;
    await queryInterface.createTable('l_category', {
      category_id: {
        type: INTEGER,
        primaryKey: true,
        unique: true,
        autoIncrement: true,
      },
      category_name: {
        type: STRING,
        allowNull: false,
        defaultValue: '',
      },
      category_cover: {
        type: STRING,
        defaultValue: '',
      },
      description: {
        type: STRING,
        defaultValue: '',
      },
      keyword: {
        type: STRING,
        defaultValue: '',
      },
      pid: {
        type: STRING,
        defaultValue: 0,
      },
      is_page: {
        type: INTEGER,
        defaultValue: 1,
        allowNull: false,
      },
      created_at: {
        type: DATE,
        defaultValue: NOW,
      },
      update_at: {
        type: DATE,
        defaultValue: NOW,
      },
    });
  },

  down: async (queryInterface, Sequelize) => {
    /*
      Add reverting commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.dropTable('users');
    */
    await queryInterface.dropTable('l_category');
  },
};
